<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true">
      <el-form-item label="撞单时间" prop="hisCustCreateTime">
        <el-date-picker
          v-model="hisCustCreateTime"
          type="daterange"
          value-format="yyyy-MM-dd"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-row style="border: 1px solid #eeeeee; padding: 10px 10px; border-radius: 10px;">
        <div class="title" style="margin-bottom: 20px;">撞单客户</div>
        <el-col span="4">
          <el-form-item label="二级销区" prop="rp03name">
            <el-input
              v-model="queryParams.rp03name"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="品牌" prop="rp05name">
            <el-input
              v-model="queryParams.rp05name"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="门店" prop="deptName">
            <el-input
              v-model="queryParams.deptName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="员工姓名" prop="hitNewCustUserName">
            <el-input
              v-model="queryParams.hitNewCustUserName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="客户姓名" prop="hitNewCustName">
            <el-input
              v-model="queryParams.hitNewCustName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="客户ID" prop="hitNewCustId">
            <el-input
              v-model="queryParams.hitNewCustId"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="border: 1px solid #eeeeee; padding: 10px 10px; border-radius: 10px;margin-top: 20px;">
        <div class="title" style="margin-bottom: 20px;">被撞单客户</div>
        <el-col span="4">
          <el-form-item label="二级销区" prop="oldRp03name">
            <el-input
              v-model="queryParams.oldRp03name"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="品牌" prop="oldRp05name">
            <el-input
              v-model="queryParams.oldRp05name"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="门店" prop="oldDeptName">
            <el-input
              v-model="queryParams.oldDeptName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="员工姓名" prop="hitOldCustUserName">
            <el-input
              v-model="queryParams.hitOldCustUserName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="客户姓名" prop="hitOldCustName">
            <el-input
              v-model="queryParams.hitOldCustName"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col span="4">
          <el-form-item label="客户ID" prop="hitOldCustId">
            <el-input
              v-model="queryParams.hitOldCustId"
              placeholder="请输入"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <!-- <el-form-item label="撞单等级" prop="hitGrade">
        <el-input
          v-model="queryParams.hitGrade"
          placeholder="请输入撞单等级"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="撞单信息" prop="hitInfo">
        <el-input
          v-model="queryParams.hitInfo"
          placeholder="请输入撞单信息"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="撞单客户id" prop="hitNewCustId">
        <el-input
          v-model="queryParams.hitNewCustId"
          placeholder="请输入撞单客户id"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="撞单导购工号" prop="hitNewCustUserCode">
        <el-input
          v-model="queryParams.hitNewCustUserCode"
          placeholder="请输入撞单导购工号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="撞单导购" prop="hitNewCustUserName">
        <el-input
          v-model="queryParams.hitNewCustUserName"
          placeholder="请输入撞单导购"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单crmid" prop="hitOldCustId">
        <el-input
          v-model="queryParams.hitOldCustId"
          placeholder="请输入被撞单crmid"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单导购code" prop="hitOldCustUserCode">
        <el-input
          v-model="queryParams.hitOldCustUserCode"
          placeholder="请输入被撞单导购code"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单导购" prop="hitOldCustUserName">
        <el-input
          v-model="queryParams.hitOldCustUserName"
          placeholder="请输入被撞单导购"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="撞单类型" prop="hitType">
        <el-select v-model="queryParams.hitType" placeholder="请选择撞单类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="撞单客户地址" prop="hitNewCustAddress">
        <el-input
          v-model="queryParams.hitNewCustAddress"
          placeholder="请输入撞单客户地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="撞单客户渠道" prop="hitNewCustChannel">
        <el-input
          v-model="queryParams.hitNewCustChannel"
          placeholder="请输入撞单客户渠道"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="撞单客户姓名" prop="hitNewCustName">
        <el-input
          v-model="queryParams.hitNewCustName"
          placeholder="请输入撞单客户姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="撞单客户电话" prop="hitNewCustPhone">
        <el-input
          v-model="queryParams.hitNewCustPhone"
          placeholder="请输入撞单客户电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="撞单客户电话类型" prop="hitNewCustPhoneType">
        <el-select v-model="queryParams.hitNewCustPhoneType" placeholder="请选择撞单客户电话类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="撞单客户状态" prop="hitNewCustStatus">
        <el-select v-model="queryParams.hitNewCustStatus" placeholder="请选择撞单客户状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="被撞单客户地址" prop="hitOldCustAddress">
        <el-input
          v-model="queryParams.hitOldCustAddress"
          placeholder="请输入被撞单客户地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单客户渠道" prop="hitOldCustChannel">
        <el-input
          v-model="queryParams.hitOldCustChannel"
          placeholder="请输入被撞单客户渠道"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="被撞单客户姓名" prop="hitOldCustName">
        <el-input
          v-model="queryParams.hitOldCustName"
          placeholder="请输入被撞单客户姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单客户电话" prop="hitOldCustPhone">
        <el-input
          v-model="queryParams.hitOldCustPhone"
          placeholder="请输入被撞单客户电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="被撞单客户电话类型" prop="hitOldCustPhoneType">
        <el-select v-model="queryParams.hitOldCustPhoneType" placeholder="请选择被撞单客户电话类型" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="被撞单客户状态" prop="hitOldCustStatus">
        <el-select v-model="queryParams.hitOldCustStatus" placeholder="请选择被撞单客户状态" clearable size="small">
          <el-option label="请选择字典生成" value="" />
        </el-select>
      </el-form-item>
      <el-form-item label="撞单客户全地址" prop="hitNewCustFullAddress">
        <el-input
          v-model="queryParams.hitNewCustFullAddress"
          placeholder="请输入撞单客户全地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="被撞单全客户地址" prop="hitOldCustFullAddress">
        <el-input
          v-model="queryParams.hitOldCustFullAddress"
          placeholder="请输入被撞单全客户地址"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sysCust:custhit:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['sysCust:custhit:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['sysCust:custhit:remove']"
        >删除</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" border stripe :data="custhitList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="撞单等级" align="center" prop="hitGrade" /> -->
      <el-table-column label="撞单基础信息" align="center">
        <el-table-column label="撞单时间" align="center" prop="createDate" width="140px">
          <template slot-scope="scope">
            <span>{{parseTime(new Date(scope.row.createDate),'{y}-{m}-{d}')}}</span>
          </template>
        </el-table-column>
        <el-table-column label="撞单等级" align="center" prop="hitGrade" width="120px">
          <template slot-scope="scope">
            <span>{{(scope.row.hitOldCustStatus!='1'&&scope.row.hitOldCustStatus!='8')||(scope.row.hitNewCustStatus!='1'&&scope.row.hitNewCustStatus!='8')?'客户撞单':'客户信息重复'}}</span>
          </template>
        </el-table-column>
        <el-table-column label="撞单项" align="center" prop="hitType" />
        <el-table-column label="当前撞单项" align="center" prop="hitType" width="120px">
          <template slot-scope="scope">
            <span v-if="scope.row.hitType=='地址'">{{scope.row.fullAddress==scope.row.oldFullAddress?'地址':'无'}}</span>
            <span v-if="scope.row.hitType=='电话'">{{scope.row.cPhone==scope.row.oldCPhone?'电话':'无'}}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column label="撞单时客户信息（撞单人）" align="center">
        <el-table-column label="创建时间" align="center" prop="crmCreateTime" width="200px">
          <template slot-scope="scope">
            <span>{{parseTime(new Date(scope.row.crmCreateTime))}}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户ID" align="center" prop="hitNewCustId" />
        <el-table-column label="客户姓名" align="center" prop="hitNewCustName" />
        <el-table-column label="客户电话" align="center" prop="hitNewCustPhone" width="120px"/>
        <!-- <el-table-column label="电话类型" align="center" prop="hitNewCustPhoneType" /> -->
        <el-table-column label="客户地址" align="center" prop="hitNewCustAddress" width="280px"/>
        <el-table-column label="渠道" align="center" prop="cChannel"  width="120px"/>
        <el-table-column label="客户状态" align="center" prop="attribute1" />
        <el-table-column label="一级销区" align="center" prop="rp02name" />
        <el-table-column label="二级校区" align="center" prop="rp03name" />
        <el-table-column label="品牌" align="center" prop="rp05name" />
        <el-table-column label="门店" align="center" prop="deptName" width="380px"/>
        <el-table-column label="姓名" align="center" prop="hitNewCustUserName" />
        <el-table-column label="工号" align="center" prop="hitNewCustUserCode"  width="100px"/>
      </el-table-column>
      <el-table-column label="撞单时客户信息（被撞单人）" align="center">
        <el-table-column label="创建时间" align="center" prop="oldCrmCreateTime"  width="180px">
          <template slot-scope="scope">
            <span>{{parseTime(new Date(scope.row.oldCrmCreateTime))}}</span>
          </template>
        </el-table-column>
        <el-table-column label="客户ID" align="center" prop="hitOldCustId" />
        <el-table-column label="客户姓名" align="center" prop="hitOldCustName" />
        <el-table-column label="客户电话" align="center" prop="hitOldCustPhone"  width="120px"/>
        <el-table-column label="电话类型" align="center" prop="hitOldCustPhoneType" />
        <el-table-column label="客户地址" align="center" prop="hitOldCustAddress"  width="380px"/>
        <el-table-column label="渠道" align="center" prop="oldCChannel" />
        <el-table-column label="客户状态" align="center" prop="oldAttribute1" />
        <el-table-column label="一级销区" align="center" prop="oldRp02name" />
        <el-table-column label="二级校区" align="center" prop="oldRp03name" />
        <el-table-column label="品牌" align="center" prop="oldRp05name" />
        <el-table-column label="门店" align="center" prop="oldDeptName"  width="380px"/>
        <el-table-column label="姓名" align="center" prop="hitOldCustUserName" />
        <el-table-column label="工号" align="center" prop="hitOldCustUserCode"  width="120px"/>
      </el-table-column>
      <el-table-column label="当前客户信息（撞单人）" align="center">
        <el-table-column label="姓名" align="center" prop="cName" />
        <el-table-column label="电话" align="center" prop="cPhone" width="120px" />
        <el-table-column label="地址" align="center" prop="fullAddress"  width="380px"/>
        <el-table-column label="状态" align="center" prop="attribute1" />
        <el-table-column label="渠道" align="center" prop="cChannel" width="120px"/>
      </el-table-column>
      <el-table-column label="当前客户信息（被撞单人）" align="center">
        <el-table-column label="姓名" align="center" prop="oldCName" />
        <el-table-column label="电话" align="center" prop="oldCPhone"  width="120px"/>
        <el-table-column label="地址" align="center" prop="oldFullAddress"  width="380px"/>
        <el-table-column label="状态" align="center" prop="oldAttribute1" />
        <el-table-column label="渠道" align="center" prop="oldCChannel" />
      </el-table-column>
      <!-- <el-table-column label="撞单crmid" align="center" prop="hitNewCustId" />
      <el-table-column label="撞单客户姓名" align="center" prop="hitNewCustName" />
      <el-table-column label="撞单客户电话" align="center" prop="hitNewCustPhone" />
      <el-table-column label="被撞单crmid" align="center" prop="hitOldCustId" />
      <el-table-column label="被撞单客户姓名" align="center" prop="hitOldCustName" />
      <el-table-column label="被撞单客户电话" align="center" prop="hitOldCustPhone" />
      <el-table-column label="撞单类型" align="center" prop="hitType" />
      <el-table-column label="撞单信息" align="center" prop="hitInfo" />

      <el-table-column label="撞单导购code" align="center" prop="hitNewCustUserCode" />
      <el-table-column label="撞单导购" align="center" prop="hitNewCustUserName" />

      <el-table-column label="被撞单导购code" align="center" prop="hitOldCustUserCode" />
      <el-table-column label="被撞单导购" align="center" prop="hitOldCustUserName" />

      <el-table-column label="撞单客户地址" align="center" prop="hitNewCustAddress" />
      <el-table-column label="撞单客户渠道" align="center" prop="hitNewCustChannel" />
      <el-table-column label="撞单客户电话类型" align="center" prop="hitNewCustPhoneType" />
      <el-table-column label="撞单客户状态" align="center" prop="hitNewCustStatus" />
      <el-table-column label="被撞单客户地址" align="center" prop="hitOldCustAddress" />
      <el-table-column label="被撞单客户渠道" align="center" prop="hitOldCustChannel" />
      <el-table-column label="被撞单客户电话类型" align="center" prop="hitOldCustPhoneType" />
      <el-table-column label="被撞单客户状态" align="center" prop="hitOldCustStatus" />
      <el-table-column label="撞单客户全地址" align="center" prop="hitNewCustFullAddress" />
      <el-table-column label="被撞单全客户地址" align="center" prop="hitOldCustFullAddress" /> -->
      <!-- <el-table-column label="操作" fixed="right" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sysCust:custhit:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['sysCust:custhit:remove']"
          >删除</el-button>
        </template> -->
      <!-- </el-table-column> -->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改撞单管理对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="唯一ID" prop="id">
          <el-input v-model="form.id" placeholder="请输入唯一ID" />
        </el-form-item>
        <el-form-item label="创建时间" prop="createDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.createDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择创建时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="是否有效" prop="isActive">
          <el-input v-model="form.isActive" placeholder="请输入是否有效" />
        </el-form-item>
        <el-form-item label="更新时间" prop="updateDate">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.updateDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择更新时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="撞单等级" prop="hitGrade">
          <el-input v-model="form.hitGrade" placeholder="请输入撞单等级" />
        </el-form-item>
        <el-form-item label="撞单信息" prop="hitInfo">
          <el-input v-model="form.hitInfo" placeholder="请输入撞单信息" />
        </el-form-item>
        <el-form-item label="撞单crmid" prop="hitNewCustId">
          <el-input v-model="form.hitNewCustId" placeholder="请输入撞单crmid" />
        </el-form-item>
        <el-form-item label="撞单导购code" prop="hitNewCustUserCode">
          <el-input v-model="form.hitNewCustUserCode" placeholder="请输入撞单导购code" />
        </el-form-item>
        <el-form-item label="撞单导购" prop="hitNewCustUserName">
          <el-input v-model="form.hitNewCustUserName" placeholder="请输入撞单导购" />
        </el-form-item>
        <el-form-item label="被撞单crmid" prop="hitOldCustId">
          <el-input v-model="form.hitOldCustId" placeholder="请输入被撞单crmid" />
        </el-form-item>
        <el-form-item label="被撞单导购code" prop="hitOldCustUserCode">
          <el-input v-model="form.hitOldCustUserCode" placeholder="请输入被撞单导购code" />
        </el-form-item>
        <el-form-item label="被撞单导购" prop="hitOldCustUserName">
          <el-input v-model="form.hitOldCustUserName" placeholder="请输入被撞单导购" />
        </el-form-item>
        <el-form-item label="撞单类型">
          <el-select v-model="form.hitType" placeholder="请选择撞单类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="撞单客户地址" prop="hitNewCustAddress">
          <el-input v-model="form.hitNewCustAddress" placeholder="请输入撞单客户地址" />
        </el-form-item>
        <el-form-item label="撞单客户渠道" prop="hitNewCustChannel">
          <el-input v-model="form.hitNewCustChannel" placeholder="请输入撞单客户渠道" />
        </el-form-item>
        <el-form-item label="撞单客户姓名" prop="hitNewCustName">
          <el-input v-model="form.hitNewCustName" placeholder="请输入撞单客户姓名" />
        </el-form-item>
        <el-form-item label="撞单客户电话" prop="hitNewCustPhone">
          <el-input v-model="form.hitNewCustPhone" placeholder="请输入撞单客户电话" />
        </el-form-item>
        <el-form-item label="撞单客户电话类型">
          <el-select v-model="form.hitNewCustPhoneType" placeholder="请选择撞单客户电话类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="撞单客户状态">
          <el-radio-group v-model="form.hitNewCustStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="被撞单客户地址" prop="hitOldCustAddress">
          <el-input v-model="form.hitOldCustAddress" placeholder="请输入被撞单客户地址" />
        </el-form-item>
        <el-form-item label="被撞单客户渠道" prop="hitOldCustChannel">
          <el-input v-model="form.hitOldCustChannel" placeholder="请输入被撞单客户渠道" />
        </el-form-item>
        <el-form-item label="被撞单客户姓名" prop="hitOldCustName">
          <el-input v-model="form.hitOldCustName" placeholder="请输入被撞单客户姓名" />
        </el-form-item>
        <el-form-item label="被撞单客户电话" prop="hitOldCustPhone">
          <el-input v-model="form.hitOldCustPhone" placeholder="请输入被撞单客户电话" />
        </el-form-item>
        <el-form-item label="被撞单客户电话类型">
          <el-select v-model="form.hitOldCustPhoneType" placeholder="请选择被撞单客户电话类型">
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="被撞单客户状态">
          <el-radio-group v-model="form.hitOldCustStatus">
            <el-radio label="1">请选择字典生成</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="撞单客户全地址" prop="hitNewCustFullAddress">
          <el-input v-model="form.hitNewCustFullAddress" placeholder="请输入撞单客户全地址" />
        </el-form-item>
        <el-form-item label="被撞单全客户地址" prop="hitOldCustFullAddress">
          <el-input v-model="form.hitOldCustFullAddress" placeholder="请输入被撞单全客户地址" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { setToken, getToken, setLesseeId } from '@/utils/auth'
import { listCusthit, getCusthit, delCusthit, addCusthit, updateCusthit, exportCusthit } from "@/api/sysCust/custhit";

export default {
  name: "Custhit",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 撞单管理表格数据
      custhitList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        hitGrade: undefined,
        hitInfo: undefined,
        hitNewCustId: undefined,
        hitNewCustUserCode: undefined,
        hitNewCustUserName: undefined,
        hitOldCustId: undefined,
        hitOldCustUserCode: undefined,
        hitOldCustUserName: undefined,
        hitType: undefined,
        hitNewCustAddress: undefined,
        hitNewCustChannel: undefined,
        hitNewCustName: undefined,
        hitNewCustPhone: undefined,
        hitNewCustPhoneType: undefined,
        hitNewCustStatus: undefined,
        hitOldCustAddress: undefined,
        hitOldCustChannel: undefined,
        hitOldCustName: undefined,
        hitOldCustPhone: undefined,
        hitOldCustPhoneType: undefined,
        hitOldCustStatus: undefined,
        hitNewCustFullAddress: undefined,
        hitOldCustFullAddress: undefined,

        rp03name:undefined,
        rp05name:undefined,
        deptName:undefined,
        oldRp03name:undefined,
        oldRp05name:undefined,
        oldDeptName:undefined,
      },
      hisCustCreateTime:[],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "唯一ID不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    let token = this.$route.query.token
    if(token){
      setToken(token)
      this.$store.commit('SET_TOKEN', token)
      setLesseeId('13')
      this.$store.commit('SET_LESSEEID', '13')
    }
    let time = new Date().getTime()
    let time7 = time - 7*24*60*60*1000
    this.hisCustCreateTime = [this.parseTime(time7, '{y}-{m}-{d}'), this.parseTime(time, '{y}-{m}-{d}')]
    this.getList();
  },
  methods: {
    /** 查询撞单管理列表 */
    getList() {
      this.loading = true;
      this.queryParams.beginTime = this.hisCustCreateTime[0]||''
      this.queryParams.endTime = this.hisCustCreateTime[1]||''
      listCusthit(this.queryParams).then(response => {
        this.custhitList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        createBy: undefined,
        createDate: undefined,
        isActive: undefined,
        updateBy: undefined,
        updateDate: undefined,
        hitGrade: undefined,
        hitInfo: undefined,
        hitNewCustId: undefined,
        hitNewCustUserCode: undefined,
        hitNewCustUserName: undefined,
        hitOldCustId: undefined,
        hitOldCustUserCode: undefined,
        hitOldCustUserName: undefined,
        hitType: undefined,
        hitNewCustAddress: undefined,
        hitNewCustChannel: undefined,
        hitNewCustName: undefined,
        hitNewCustPhone: undefined,
        hitNewCustPhoneType: undefined,
        hitNewCustStatus: "0",
        hitOldCustAddress: undefined,
        hitOldCustChannel: undefined,
        hitOldCustName: undefined,
        hitOldCustPhone: undefined,
        hitOldCustPhoneType: undefined,
        hitOldCustStatus: "0",
        hitNewCustFullAddress: undefined,
        hitOldCustFullAddress: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加撞单管理";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getCusthit(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改撞单管理";
      });
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateCusthit(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addCusthit(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$confirm('是否确认删除撞单管理编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCusthit(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有撞单管理数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportCusthit(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>
